package com.cci.kangdao.dao;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.mybatis.spring.annotation.MapperScan;

import java.util.Map;

/**
 * 服务工单自主诊断dao
 *
 */
@MapperScan
public interface WorkOrderSelfDiagnosticTDao {

	int insert(Map<String,Object> map);

	//根据工单id获取自行诊断
	@Select("select top 1 WorkOrderId,DiagnosticDesc,InspectDesc,RepairDesc,ReplacePart,\n" +
			"case when ReplacePart = 0 then '' else ComponentName end as ComponentName,IsWorked,b.Contact as technicianName\n" +
			"from WorkOrderSelfDiagnostic_T a \n" +
			"left join User_T b on a.Creator = b.ID \n" +
			"where a.WorkOrderId = #{orderId} and a.Flag = 0 order by a.CreateTime desc")
	Map<String,Object> getSelfDiagnosticDetail(@Param("orderId")long orderId);
}
